from PredictAllCells.readJsonData import read_json_to_matrix
from PredictAllCells.train_all_cells import train_model_all_cells
from PredictAllCells.predict_by_model import predict_all_cells
import os.path

if __name__ == '__main__':

    # 参数设置
    json_path = '../bock_count_json'      # json文件夹路径
    model_save_path = './models/lstm_model_number_all_cells.h5'            # 模型保存路径
    rows = 25                 # 格子行
    columns = 45              # 格子列
    time_step = 1             # 时间步长

    # 获取数据
    train_data = read_json_to_matrix(json_path, rows, columns)

    # 训练并保存模型
    if not os.path.exists(model_save_path):
        train_model_all_cells(train_data, rows, columns, model_save_path, time_step, epochs=100, split=0.8)
        print("model trained and saved")

    # 利用训练好的模型进行预测
    predict_data = train_data
    predict_value, true_value = predict_all_cells(model_save_path, predict_data, rows, columns, time_step)
    # predict_value: 预测的结果，维度为：[小时数，格子行数，格子列数]
    # true_value:    真实的结果，维度为：[小时数，格子行数，格子列数]









